Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ReadWriteMultipleRegister support #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pieterg
Copy link

@pieterg pieterg commented Apr 20, 2023

ReadWriteMultipleRegister support is not working, because the generated frame is incomplete.
The frame is created by ModbusMessageImpl.MessageFrame, which calls ModbusMessageImpl.ProtocolDataUnit internally, instead of the overridden ReadWriteMultipleRegisterRequest.ProtocolDataUnit.
By overriding ModbusMessageImpl.MessageFrame in ReadWriteMultipleRegisterRequest (duplicating the implementation, there might be a better solution), the generated ReadWriteMultipleRegister frame will be correct.
After fixing this, I found that the response is rejected, because ReadWriteMultipleRegisters was is not in the functionCode switch.

These commits result in working ReadWriteMultipleRegister support (tested with RTU)

pieterg added 3 commits April 20, 2023 14:49
so it can be overridden by classes which need to override ProtocolDataUnit
When using the base class MessageFrame implementation, it will call the base class ProtocolDataUnit, resulting in an invalid/incomplete message frame.
By overriding MessageFrame,  our overridden ProtocolDataUnit will be called instead.
ReadWriteMultipleRegisters response is the same as a ReadHoldingRegisters response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant